package learningThread.api.stopApi;

/**
 * interrupt并不能直接马上关闭线程，还需要判断线程是否是停止状态，可通过 interrupted 获取当前线程是否为 中止状态
 */
public class TestThread {

    public static void main(String[] args) {

        try {
            //继承Thread
            MyThread thread = new MyThread();
            thread.start();
            Thread.sleep(2000);
            thread.interrupt();

            System.out.println("停止 1:"+thread.isInterrupted());
            System.out.println("停止 2:"+thread.isInterrupted());
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

    }
}
